﻿using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
using Ebusiness_UserService.Services;
using Ebusiness_UserService.Services.Dtos.User;

namespace Ebusiness_UserService.Controllers;


[Route("User/[action]")]
[ApiController]
public class UserController : AbpController , IUserService
{
    public IUserService  userService { get; set; }

    public UserController()
    {

    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="productDto"></param>
    /// <returns></returns>
    //[UnitOfWork(typeof(Ebusiness_UserServiceDbContext))]
    //[HttpPost]
    //public async Task<UserDto> Create(UserDto productDto)
    //{
    //    var dto = await userService.CreateAsync(productDto);
    //    return dto;
    //}

    /// <summary>
    /// 获取列表数据
    /// </summary>
    /// <returns></returns>
    //[HttpGet]
    //public async Task<List<UserDto>> GetList()
    //{
    //    var dtos = await userService.GetListAsync(new PagedAndSortedResultRequestDto() { MaxResultCount = 50, SkipCount = 0 });
    //    return dtos.Items.ToList();
    //}

    [HttpPost]
    public async Task<string> LoginByPhoneAndPwd(LoginByPhoneAndPwdRequest req)
    {
        return await userService.LoginByPhoneAndPwd(req);
    }

    [HttpGet]
    public async Task<UserDto> GetAsync(Guid id)
    {
        return await userService.GetAsync(id);
    }

    [HttpPost]
    public async Task<PagedResultDto<UserDto>> GetListAsync(PagedAndSortedResultRequestDto input)
    {
        return await userService.GetListAsync(input);
    }

    [HttpPost]
    public async Task<UserDto> CreateAsync(UserDto input)
    {
        return await userService.CreateAsync(input);
    }

    [HttpPut]
    public async Task<UserDto> UpdateAsync(Guid id, UserDto input)
    {
        return await userService.UpdateAsync(id, input);
    }

    [HttpDelete]
    public async Task DeleteAsync(Guid id)
    {
        await userService.DeleteAsync(id);
    }

    //[HttpGet]
    //public async Task<List<User>> GetByUserList()
    //{
    //    return await userService.GetByUserList();
    //}
}
